package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.model.User;
import com.zr.service.FindUnameService;

@Controller
@Scope(value="prototype")
public class Finduname implements ServletResponseAware{
	
	private int uid;
	private HttpServletResponse resp;
	
	
	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}
	@Resource
	private FindUnameService findu;
	
	public void findu(){
		User u = findu.findUname(uid);
		String uname = u.getUname();
		try {
			PrintWriter pw = resp.getWriter();
			pw.write(uname);
			pw.flush();
			pw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	@Override
	public void setServletResponse(HttpServletResponse resp) {
		this.resp= resp;
	}
}
